library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity binary_multiplier is
    Port ( a : in  STD_LOGIC_VECTOR (1 downto 0);
           b : in  STD_LOGIC_VECTOR (1 downto 0);
           product : out  STD_LOGIC_VECTOR (3 downto 0));
end binary_multiplier;

architecture Behavioral of binary_multiplier is
begin
    process (a, b)
        variable partial_product1, partial_product2 : std_logic_vector(2 downto 0);
    begin
        -- 计算部分乘积
        partial_product1 := ('0' & a) * b(0); -- a * b0
        partial_product2 := ('0' & a) sll 1 * b(1); -- a * 2 * b1
        
        -- 将部分乘积相加得到最终结果
        product <= std_logic_vector(unsigned(partial_product1) + unsigned(partial_product2));
    end process;
end Behavioral;